<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>

<body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>上级菜单
                </label>
                <div id="pMenu">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>菜单名称
                </label>
                <div class="layui-input-block">
                    <input type="text" name="name" id="name" placeholder="菜单名称" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    访问地址
                </label>
                <div class="layui-input-block">
                    <input type="text" name="path" id="path" placeholder="访问地址" autocomplete="off" class="layui-input"
                        value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    图标
                </label>
                <div class="layui-input-block">
                    <input type="text" name="icon" id="icon" placeholder="图标" autocomplete="off" class="layui-input"
                        value="" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    状态
                </label>
                <div class="layui-input-block">
                    <select name="hide" id="hide">
                        <option value="0">显示</option>
                        <option value="1">隐藏</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    排序
                </label>
                <div class="layui-input-block">
                    <input type="text" name="sort" id="sort" placeholder="排序" autocomplete="off" class="layui-input"
                        value="" />
                </div>
            </div>

            <!-- <input type="hidden" name="pid" id="pid" value="" /> -->
            <input type="hidden" name="id" id="id" value="" />
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />
        </form>
    </div>
    <script>
        let params = {
            addUrl: '/admin/menu/add',
            editUrl: '/admin/menu/edit',
            detailUrl: '/admin/menu/detail',
        }
        form_ajax(params)

        let selectParams = {
            url:'/admin/menu/list',
            elem: '#pMenu',
            selected: GetQueryString('pid')?.split(','),
            max: 1,
            tips: '菜单列表',
            name: 'pid',
            field_id:'id',
            field_Name:'title_show',
            extraData:[{ id: 0, title_show: '顶级菜单' }]
        }
        selectN(selectParams)
    </script>
</body>

</html>